#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
using namespace std;

class Solution {
public:
    vector<vector<string>> partition(string s) {
        if(s.empty()){
            return {{}};
        }
        vector<vector<string>> result;
        vector<string> sonResult;
        func(s,0,sonResult,result);
        return result;
    }
    void func(string& s,int index,vector<string> sonResult, vector<vector<string>>& result){
        if(index==s.size()){
            result.push_back(sonResult);
            return ;
        }
        for(int i = index;i<s.size();++i){
            string temp = string(s.begin()+index,s.begin()+1+i);
            if(isfunc(temp)){
                sonResult.push_back(temp);
                func(s,i+1,sonResult,result);
                sonResult.pop_back();
            }
            
        }
    }
    bool isfunc(string& s){
        //判断字符串s是否是回文字符串
        int i = 0;
        int j = s.size()-1;
        while(i<=j){
            if(s[i]!=s[j]){
                return false;
            }
            ++i;
            --j;
        }
        return true;

    }
};


int main(){
    Solution S;
    vector<vector<string>> result = S.partition("aab");
    return 0;
}